package com.totem.base.logger.filter;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;

public abstract class AbstractLoggerFilter extends Filter<ILoggingEvent> {

    @Override
    public FilterReply decide(ILoggingEvent event) {
        FilterReply reply = filter(event.getLevel());
        return reply;
    }

    private FilterReply filter(Level level){
        if(checkLevel(level.levelInt)){
            return FilterReply.ACCEPT;
        }else {
            return FilterReply.DENY;
        }
    }

    protected abstract boolean checkLevel(int level);
}
